#include "Animal.h"
#include "Monkey.h"
#include "People.h"
#include <stdio.h>
#include "MyList.h"

int main(){
    MOAnimal *an1=mo_monkey_new();  //由于Monkey和People都继承自Animal，所以可以将其指针赋给Animal的指针
    MOAnimal *an2=mo_people_new();  //People继承自Monkey,间接继承自Animal

    printf("猴子叫:%s,人叫:%s,人讲藏话:%s \n",  //这里体现了多态，同一个方法不同子类结果不一样
            mo_animal_get_cry(an1),                 //子类可以用父类的函数
            mo_animal_get_cry(an2),
            mo_people_dj(an2));                     //子类也有单独的函数

    MyList *l1=mo_mylist_new(4);

	int a[]={1,2,3,5,6,8,10};

	for (int i=0; i<7; i++) {
		mo_mylist_add_tail(l1, &a[i]);
	}

	MyList *l2=mo_mylist_new_fromlist(l1);
	for (int i=0; i<7; i++) {
		mo_mylist_add_head(l2, &a[i]);
	}

	int getter=0;

	for (mo_list_iter iter=mo_mylist_start(l1); iter.var!=NULL; mo_mylist_iter_next(&iter)) {
		mo_get_iter_var(&getter, iter);
		printf("%d,\n",getter);
	}

	for (mo_list_iter iter=mo_mylist_start(l2); iter.var!=NULL; mo_mylist_iter_next(&iter)) {
		mo_get_iter_var(&getter, iter);
		printf("%d,\n",getter);
	}

	mo_mylist_delete(l1);
	mo_mylist_delete(l2);
	return 0;
}